class Solution {
public:
    string largestGoodInteger(string num) {
        int n = num.size();
        char mx = 0;
        for(int i = 0; i < n - 2; ++i)
        {
            char tmp = num[i];
            if(tmp > mx && num[i] == num[i + 1] && num[i + 1] == num[i + 2])
            {
                mx = tmp;
            }
        }
        return mx ? string(3, mx) : "";
    }
};
